/*
 * @Author: Sam
 * @Date: 2025-04-28 17:40:45
 * @LastEditTime: 2025-10-09 10:18:28
 * @LastEditors: Sam
 */
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import { viteExternalsPlugin } from 'vite-plugin-externals'

// https://vite.dev/config/
export default defineConfig({

	server:{
		host:'0.0.0.0',

		//热更新不涉及canvas，尽量关闭，通过手动刷新浏览器实现
		hmr:false,
	},
	plugins: [
		vue(),
		vueJsx(),
		// vueDevTools(),


		//gis-viewer通过cdn umd的方式引入
		viteExternalsPlugin({
			'gis-viewer': 'GISViewer',
		}),
		{
			name: 'reload-on-js-change',
			handleHotUpdate({ file, server }) {
				server.ws.send({
					type: 'full-reload',
					path: '*',
				})
				return []
			},
		},
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url))
		},
	},
})
